<?php
//Connection statement
require_once('../../Connections/cn.php');

//Aditional Functions
require_once('../../includes/functions.inc.php');

// build the form action
$editFormAction = $_SERVER['PHP_SELF'] . (isset($_SERVER['QUERY_STRING']) ? "?" . $_SERVER['QUERY_STRING'] : "");

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO libro (id_material) VALUES (%s)",
                       GetSQLValueString($_POST['hiddenField'], "int"));

  $Result1 = $cn->Execute($insertSQL) or die($cn->ErrorMsg());
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO libro (id_material, id_editorial, titulo_libro, describe_libro, isbn_libro, ann_libro, edicion_libro, formato_libro, paginas_libro, indice_libro, prologo_libro, caratula_libro) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['id_material'], "int"),
                       GetSQLValueString($_POST['id_editorial'], "int"),
                       GetSQLValueString($_POST['titulo_libro'], "text"),
                       GetSQLValueString($_POST['describe_libro'], "text"),
                       GetSQLValueString($_POST['isbn_libro'], "text"),
                       GetSQLValueString($_POST['ann_libro'], "int"),
                       GetSQLValueString($_POST['edicion_libro'], "text"),
                       GetSQLValueString($_POST['formato_libro'], "text"),
                       GetSQLValueString($_POST['paginas_libro'], "int"),
                       GetSQLValueString($_POST['indice_libro'], "text"),
                       GetSQLValueString($_POST['prologo_libro'], "text"),
                       GetSQLValueString($_POST['caratula_libro'], "text"));

  $Result1 = $cn->Execute($insertSQL) or die($cn->ErrorMsg());
}

// begin Recordset
$query_Reco_editorial = "SELECT id_editorial, nombre_editorial FROM editorial";
$Reco_editorial = $cn->SelectLimit($query_Reco_editorial) or die($cn->ErrorMsg());
$totalRows_Reco_editorial = $Reco_editorial->RecordCount();
// end Recordset

//PHP ADODB document - made with PHAkt 3.6.0
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<script type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>

<body>
<?
$area=$_POST['id_area'];
$coleccion=$_POST['id_coleccion'];
$codigo_barra=$_POST['codigo'];
$dewey=$_POST['coddewey'];
$precio=$_POST['precio_material'];
$copia=$_POST['copia_material'];
//$material=$_POST['material']
?>
MATERIAL
<form id="form1" name="form1" method="POST" action="">
  <table width="456" border="1">
    <tr>
      <td width="197">&Aacute;rea</td>
      <td width="243"><? echo $area?></td>
    </tr>
    <tr>
      <td>Colecci&oacute;n</td>
      <td><? echo $coleccion?></td>
    </tr>
    <tr>
      <td>C&oacute;digo Barra </td>
      <td><? echo $codigo_barra?></td>
    </tr>
    <tr>
      <td>C&oacute;digo Dewey </td>
      <td><? echo $dewey?></td>
    </tr>
    <tr>
      <td>Precio </td>
      <td><? echo $precio?></td>
    </tr>
    <tr>
      <td>Copia</td>
      <td><? echo $copia ?></td>
    </tr>
  </table>
  <? 
  switch($material)
 		  {
		   case "1": ?>
		   INGRESO LIBRO
		   <table width="200" border="1">
  			<tr>
    			<td width="105">&nbsp;</td>
    			<td width="79"><input type="hidden" name="id_material"></td>
  			</tr>
  			<tr>
    			<td>Editorial</td>
    			<td><select name="id_editorial" onChange="">
    			  <?php
  while(!$Reco_editorial->EOF){
?><option value="<?php echo $Reco_editorial->Fields('id_editorial')?>"><?php echo $Reco_editorial->Fields('nombre_editorial')?></option>
    			  <?php
    $Reco_editorial->MoveNext();
  }
  $Reco_editorial->MoveFirst();
?>
                                </select></td>
  			</tr>
  			<tr>
    			<td height="45">Titulo</td>
    			<td><label>
    			  <input type="text" name="titulo_libro">
    			</label></td>
  			</tr>
  			<tr>
    			<td>Descripci&oacute;n</td>
    			<td><label>
    			  <input type="text" name="describe_libro">
    			</label></td>
  			</tr>
  			<tr>
    			<td>ISBN</td>
    			<td><label>
    			  <input type="text" name="isbn_libro">
    			</label></td>
  			</tr>
  			<tr>
    			<td>A&ntilde;o</td>
    			<td><label>
    			  <input type="text" name="ann_libro">
    			</label></td>
  			</tr>
  			<tr>
  			  <td>Edici&oacute;n</td>
  			  <td><label>
  			    <input type="text" name="edicion_libro">
  			  </label></td>
		     </tr>
  			<tr>
  			  <td>Formato</td>
  			  <td><label>
  			    <input type="text" name="formato_libro">
  			  </label></td>
		     </tr>
  			<tr>
  			  <td>Paginas</td>
  			  <td><label>
  			    <input type="text" name="paginas_libro">
  			  </label></td>
		     </tr>
  			<tr>
  			  <td>Indice</td>
  			  <td><label>
  			    <input type="text" name="indice_libro">
  			  </label></td>
		     </tr>
  			<tr>
  			  <td>Prologo</td>
  			  <td><label>
  			    <input type="text" name="prologo_libro">
  			  </label></td>
		     </tr>
  			<tr>
  			  <td>Caratula</td>
  			  <td><label>
  			    <input type="file" name="caratula_libro">
  			  </label></td>
		     </tr>
  </table>
<? 
		        	echo "1";
				break;	 
			case "2":
		           echo "2";
				break;	
					
			case "3":
		            echo "3";
				break;	 	 
		  
		   } 
	?>	   
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <input type="hidden" name="MM_insert" value="form1">
</form>
</body>
</html>
<?php
$Reco_editorial->Close();
?>
